import { useEffect } from "react";
import { UserType } from "types";
import useServer from "server";
import { useAsync } from "hooks";

export const useUsers = () => {
  const client = useServer();
  const { run, ...result } = useAsync<UserType[]>();

  useEffect(() => {
    run(client("users"));
  }, [client, run]);

  return result;
};
